"use client";

import { useAuth } from "@/context/AuthContext";
import { Button } from "@/components/ui/button";
import Link from "next/link";

export default function HomePage() {
  const { isAuthenticated, logout } = useAuth();

  return (
    <main className="flex flex-1 flex-col items-center justify-center p-6">
      <div className="text-center">
        <h1 className="text-4xl font-bold mb-4">欢迎来到 Mobile H5 App</h1>
        {isAuthenticated ? (
          <div>
            <p className="text-lg mb-6">您已成功登录。</p>
            <Button onClick={logout} className="bg-red-500 hover:bg-red-600 text-white">
              登出
            </Button>
          </div>
        ) : (
          <div>
            <p className="text-lg mb-6">请登录以继续。</p>
            <Link href="/login">
              <Button className="bg-blue-500 hover:bg-blue-600 text-white">前往登录</Button>
            </Link>
          </div>
        )}
      </div>
    </main>
  );
}
